package com.climber.spb_rabbitmq.spb_lazy.service;

import com.climber.spb_rabbitmq.utils.RabbitMQUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class AConsumer2Lazy {

    public static void main(String[] args) {
        try {
            Channel channel = RabbitMQUtils.getChannel();
            System.out.println("MConsumer2*********");
            DeliverCallback deliverCallback=(consumerTag,message)->{
                String s = new String(message.getBody(), StandardCharsets.UTF_8);
                System.out.println("consumer2 received message : "+s);
                System.out.println("consumer2 finished");
            };
            CancelCallback cancelCallback=(consumerTag)->{
                System.out.println(consumerTag);
                System.out.println("receive interrupted");
            };
            channel.basicConsume("lazy",true,deliverCallback,cancelCallback);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
}
